//动态申请结构体数组
#include<iostream>
#include<cstring>
#define _CRT_SECURE_NO_WARNINGS//高版本VS中strcmp等函数被视为不安全的，会报错加上这句话就行
using namespace std;
struct STU {
	char name[40];
	char sex[10];
	int age;
};
int main()
{
	int n;
	cin >> n;
	STU* p;
	p = new STU[n];
	STU* q = p;
	int num = 0;//计数
	cin >> q->name >> q->sex >> q->age;
	while (strcmp(q->name, "0") != 0 && strcmp(q->sex, "0") != 0 && q->age != 0)//万一有人叫0呢，狗头
	{
		q++;
		num++;
		cin >> q->name >> q->sex >> q->age;
	}
	q = p + num - 1;//q指向末尾
	while (q >= p)
	{
		cout << q->name << " " << q->sex << " " << q->age << endl;
		q--;
	}
	delete[] p;
}
